const express = require('express')
const app = express()

// 加载所有JSON文件
const data = {
  buildings: require('./src/assets/Wuhan_Buildings.json'),
  roads: require('./src/assets/Wuhan_roads.json'),
  events: require('./src/assets/Wuhan_events.json'),
  bridge: require('./src/assets/Wuhan_bridge.json')
}

// 配置四个接口
app.get('/Wuhan_buildings', (req, res) => res.json(data.buildings.features))
app.get('/Wuhan_roads', (req, res) => res.json(data.roads.features))
app.get('/Wuhan_events', (req, res) => res.json(data.events.features))
app.get('/Wuhan_bridge', (req, res) => res.json(data.bridge.features))

// 启动服务器
app.listen(3000, () => {
  console.log(`
  API 已启动！
  建筑数据: http://localhost:3000/Wuhan_buildings
  道路数据: http://localhost:3000/Wuhan_roads
  事件数据: http://localhost:3000/Wuhan_events
  桥梁数据: http://localhost:3000/Wuhan_bridge
  `)
})